* Table 2
* load pelec9914 dataset
* Create interaction term and constituency-year fixed effect
egen const_year = group(constituency year)
gen govincumb =gov*incumb
gen minstgov=min*stgov
* Create party fixed effect
encode party, generate(newparty)
* Create Table 2: Ministerial Office and Electoral Outcomes
eststo clear
reg voteshare min incumb, cluster(id)
eststo
reg voteshare min incumb gov govincumb, cluster(id)
eststo
reg voteshare min incumb gov govincumb i.newparty, cluster(id)
eststo
areg voteshare min incumb gov govincumb, absorb(const_year) cluster(id)
eststo
areg voteshare min incumb gov govincumb i.newparty, absorb(const_year) cluster(id)
eststo
areg voteshare min incumb gov govincumb stgov i.newparty, absorb(const_year) cluster(id)
eststo
areg voteshare min incumb gov govincumb stgov minstgov i.newparty, absorb(const_year) cluster(id)
eststo
esttab using Table2.csv, replace compress r2 se b(%9.3f) se(%9.3f)

*Calculate the effect of the interaction between Ministerial Office and State Government in model 7 which provides the differing effect of holding ministerial office on a candidate’s vote share conditional on the party ruling in the candidate’s home state

*Install ICALC if you do not already have it running
net from http://www.icalcrlk.com

areg voteshare min incumb gov govincumb stgov minstgov i.newparty, absorb(const_year) cluster(id)
intspec focal(min) main( (min ,  name(Ministerial_Office) range(0/1)) (stgov,  name(State_Government)  range(0/1))) int2(minstgov) ndig(4) abbrevn(14)
gfi, ndig(5)
sigreg, sig(.05) ndig(5)
outdisp,  tab(row(mod))

